<script type="text/javascript">
    function validate(obj)
    {
      if(obj.uname.value=="") {
        alert('Name should not be blank.');
        obj.uname.focus();
        return false;
      }
      if(obj.uname.value.length < 6) {
        alert('Name should be 6 char long');
        obj.uname.focus();
        obj.uname.select();
        return false;
      }

      return true;
    }

</script>

<form action="" onSubmit="return validate(this)" method="get">
  <input type="text" placeholder="My name is" name="uname" />
  <input type="password" placeholder="My password is"  name="password"   />
  <input type="submit" value="I am done!!" />
</form>
